package com.sky.controller;

import com.sky.dto.VueTemplateAddRequest;
import com.sky.service.VueFormTemplateService;
import com.sky.result.Result;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/admin/formtemplate")
@RequiredArgsConstructor
public class VueFormTemplateController {
    private final VueFormTemplateService templateService;

    @PostMapping("/add")
    public Result addTemplate(@RequestBody VueTemplateAddRequest request) {
        return templateService.addTemplate(request);
    }

    @GetMapping("/detail/{id}")
    public Result getTemplateDetail(@PathVariable Long id) {
        return templateService.getTemplateDetail(id);
    }

    @PostMapping("/update/{id}")
    public Result updateTemplate(@PathVariable Long id, @RequestBody VueTemplateAddRequest request) {
        request.setId(id);  // 设置要更新的模板ID
        return templateService.updateTemplate(request);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteTemplate(@PathVariable Long id) {
        return templateService.deleteTemplate(id);
    }
}